package com.zian.controller.admin;


import com.zian.annotation.OperLog;
import com.zian.common.R;
import com.zian.domain.dto.*;
import com.zian.domain.po.SysUser;
import com.zian.domain.query.UserQuery;
import com.zian.domain.vo.UserQueryVO;
import com.zian.enums.BusinessType;
import com.zian.service.ISysUserService;
import com.zian.validation.UserCroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author
 * @since 2024-09-08
 */
@Slf4j
@Api("用户接口")
@RestController("SysUserControllerAdmin")
@RequestMapping("/admin/users")
@RequiredArgsConstructor
public class SysUserController {

    private final ISysUserService userService;


    @GetMapping("/page")
    @ApiOperation("分页查询")
    public R<PageDTO<UserQueryVO>> queryPage(UserQuery query) {
        log.info("分页查询参数：{}", query);
        return R.ok(userService.queryPage(query));
    }

    @PutMapping
    @ApiOperation("禁用或者启用")
    @OperLog(title = "用户管理", businessType = BusinessType.UPDATE)
    public R updateLockedByIds(@RequestBody UserLockedDTO dto) {
        log.info("禁用或者启用参数：{}", dto);
        userService.updateLockedByIds(dto);
        return R.ok();
    }
}
